aboutsummaryrefslogtreecommitdiffstats
path: root/pages/api/notes/[id].js
diff options
context:
space:
mode:
authorGravatar piotrruss <mail@pruss.it> 2021-09-06 23:13:22 +0200
committerGravatar piotrruss <mail@pruss.it> 2021-09-06 23:13:22 +0200
commit569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a (patch)
tree8d1cb94a56d60b9d726222277b7516fc59895613 /pages/api/notes/[id].js
parent275bd1d0a9aea90696c145cf992d522a0d6b0aa8 (diff)
downloadmy_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.tar.gz
my_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.tar.bz2
my_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.zip
added stadard linter
Diffstat (limited to 'pages/api/notes/[id].js')
-rw-r--r--pages/api/notes/[id].js14
1 files changed, 7 insertions, 7 deletions
diff --git a/pages/api/notes/[id].js b/pages/api/notes/[id].js
index 58e458f..12f0ba4 100644
--- a/pages/api/notes/[id].js
+++ b/pages/api/notes/[id].js
@@ -4,7 +4,7 @@ import NoteList from 'models/NoteList'
import Note from 'models/Note'
export default withSession(async (req, res) => {
- const {id: _id} = req.query
+ const { id: _id } = req.query
await dbConnect()
switch (req.method) {
@@ -12,7 +12,7 @@ export default withSession(async (req, res) => {
try {
const user = req.session.get('user')
- if (!user || !user?.isVerified || !_id ) {
+ if (!user || !user?.isVerified || !_id) {
throw new Error('Something went wrong')
}
@@ -25,7 +25,7 @@ export default withSession(async (req, res) => {
res.status(200).json(note)
} catch (error) {
console.log(error)
- res.status(400).json({error: true})
+ res.status(400).json({ error: true })
}
break
case 'DELETE':
@@ -37,10 +37,10 @@ export default withSession(async (req, res) => {
}
const noteId = await NoteList.getNoteId(user.noteList, _id)
- if ( !noteId) throw new Error('Something went wrong')
+ if (!noteId) throw new Error('Something went wrong')
await Note.findByIdAndDelete(noteId)
- const {notes} = await NoteList.removeNote(user.noteList, _id)
+ const { notes } = await NoteList.removeNote(user.noteList, _id)
res.status(200).json(notes)
} catch (error) {
@@ -51,14 +51,14 @@ export default withSession(async (req, res) => {
case 'PUT':
try {
const user = req.session.get('user')
- const {title, noteId, content} = req.body
+ const { title, noteId, content } = req.body
if (!user || !user?.isVerified || !_id || !content) {
throw new Error('Something went wrong')
}
await Note.updateNote(noteId, content)
- const {notes} = await NoteList.updateList(user.noteList, noteId, title)
+ const { notes } = await NoteList.updateList(user.noteList, noteId, title)
res.status(200).json(notes)
} catch (error) {